<template>
  <div class="card">
    <div>{{ user[0]?.username }}</div>
    <p><strong>id:</strong>{{ user[0]?.id }}</p>
  </div>
</template>

<script setup>
import { getUserinfo } from '@/api/mockData'
import { ref, reactive } from 'vue'
const user = ref([])
let user1 = reactive({
  data: '',
})

const fetchUser = async () => {
  const { data } = await getUserinfo()
  user.value = data // 正确更新ref的值
  const data1 = await getUserinfo()
  user1.data = data1.data
  console.log('user1', user1.data)
}

await fetchUser()
</script>

<style scoped></style>
